﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
namespace AnyOffice.general.attend.manage
{
    public partial class evection_reason : ModulePage
    {
      
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
                int num = (Request.QueryString["evection_id"] != null) ? int.Parse(Request.QueryString["evection_id"].ToString()) : 0;
                this.ViewState["EvectionId"] = num;
                bool flag = (Request.QueryString["is_mobile"] != null) ? bool.Parse(Request.QueryString["is_mobile"].ToString()) : false;
                this.ViewState["IsMobile"] = flag;
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                int evectionId = Convert.ToInt32(this.ViewState["EvectionId"].ToString());
                bool isMobile = Convert.ToBoolean(this.ViewState["IsMobile"].ToString());
                new AttendEvectionDao().Reason(base.Conn, evectionId, this.txtReason.Value);
                if (isMobile)
                {
                    DataTable table = new AttendEvectionDao().SelectByEvectionId(base.Conn, evectionId);
                    if (table.Rows.Count > 0)
                    {
                        SmsData data = new SmsData();
                        SmsDao dao = new SmsDao();
                        data.Type = 6;
                        data.FromId = base.User.Identity.Name;
                        data.ToId = table.Rows[0]["UserId"].ToString();
                        data.Content = "您的出差申请未被批准！";
                        data.RemindFlag = true;
                        data.SendTime = DateTime.Now;
                        dao.BizSend(base.Conn, data, true, isMobile);
                    }
                }
                this.litMessage.Text = base.ShowPromptClose("操作成功！") + "\n<script>\nopener.location.reload();\n</script>\n";
            }
        } 

    }
}
